<!--
 * @Descripttion: 
 * @LastEditors: xzh
 * @LastEditTime: 2023-08-07 19:21:13
-->
<template>
  <svg
    :class="svgClass"
    v-bind="$attrs"
    :style="{ color: color, width: `${size}rem`, height: `${size}rem` }"
  >
    <use :xlink:href="iconName"></use>
  </svg>
</template>

<script setup lang="ts">
import { computed } from "vue";
const props = defineProps({
  name: {
    type: String,
    required: true,
  },
  color: {
    type: String,
    default: "",
  },
  size: {
    type: Number,
    default: 1,
  },
});
const iconName = computed(() => `#icon-${props.name}`);
const svgClass = computed(() => {
  if (props.name) return `svg-icon icon-${props.name}`;
  return "svg-icon";
});
</script>

<style scoped>
.svg-icon {
  fill: currentColor;
  vertical-align: middle;
  outline: none;
}
</style>
